package ru.amse.tsyganov.jumleditor.model;

import org.w3c.dom.Element;
import org.w3c.dom.Node;



public class ActionState extends State {
	
	private final static String CALL_ACTION_MODE = "callActionMode"; 
	
	public enum CallActionMode {
		SYNCHRONOUS {
			public String toString() {
				return "Synchronous";
			}
		},
		
		ASYNCHRONOUS {
			public String toString() {
				return "Asynchronous";
			}
		};
		
		public abstract String toString();
	}
	
	private CallActionMode callActionMode = CallActionMode.SYNCHRONOUS;

	public CallActionMode getCallActionMode() {
		return callActionMode;
	}

	public void setCallActionMode(CallActionMode callActionMode) {
		this.callActionMode = callActionMode;
	}

	@Override
	public void readFromXml(Node element) {
		super.readFromXml(element);
		setCallActionMode(CallActionMode.valueOf(
				element.getAttributes().getNamedItem(
						CALL_ACTION_MODE).getNodeValue()));
	}

	@Override
	public void writeToXml(Element element) {
		super.writeToXml(element);
		element.setAttribute(CALL_ACTION_MODE, 
				getCallActionMode().name());
	}

}
